////
////  YRShareViewController.swift
////  Browser
////
////  Created by 薛永伟 on 2019/4/3.
////  Copyright © 2019年 114la.com. All rights reserved.
////
//
//import Foundation
//
//extension YRShare.UI{
//
//    /** 分享UI控制器，仅UI展示。
//     ## 此类禁止绑定任何数据，禁止绑定分享点击的操作。
//     由于使用分享的类极个别，且点击后操作请求等多变，而分享大部分代码重复，可直接拷贝已有代码，并进行个性化修改。
//     无需过度封装，造成不必要的污染。
//     */
//    class YRShareViewController:UIViewController{
//
//        var dataSource:[YRShare.Feature.ItemTarget] = [YRShare.Feature.ItemTarget]()
//
//        typealias ShareClickHandle = (_ type:YRShare.Feature.ItemTarget)->()
//
//        var clickHandle:ShareClickHandle
//
//        /// 分享方式，经验和商家是特殊的UI
//        var shareType:ShareUIType
//
//        /// shareTypes传空则默认使用全部可用的类型
//        init(shareTypes:[YRShare.Feature.ItemTarget]?,shareType:ShareUIType,shareClickHandle:@escaping ShareClickHandle) {
//
//            if let types = shareTypes{
//                dataSource = types
//            }else{
//
//                if YRShare.Feature.ItemTarget.weixin.isAvailable {
//                    dataSource.append(.weixin)
//                    dataSource.append(.weixinDynamic)
//                }
//                if YRShare.Feature.ItemTarget.qqFriend.isAvailable{
//                    dataSource.append(.qqFriend)
//                    dataSource.append(.qqZone)
//                }
//                if YRShare.Feature.ItemTarget.weibo.isAvailable {
//                    dataSource.append(.weibo)
//                }
//
//                dataSource.append(.moreShare)
//            }
//
//            self.clickHandle = shareClickHandle
//            self.shareType = shareType
//
//            super.init(nibName: nil, bundle: nil)
//
//            self.modalPresentationStyle = .overFullScreen
//        }
//
//        required init?(coder aDecoder: NSCoder) {
//            fatalError("init(coder:) has not been implemented")
//        }
//
//
//        lazy var contentView: ContentView = {
//
//            let view = ContentView()
//            view.collectionView.register(ShareItemCell.self, forCellWithReuseIdentifier: "ShareItemCell")
//            view.collectionView.delegate = self
//            view.collectionView.dataSource = self
//            view.backBtn.addTarget(self, action: #selector(onCloseClick), for: .touchUpInside)
//            return view
//        }()
//
//        /// 经验特殊视图
//        lazy var experienceView: ExperienceHead = {
//
//            let view = ExperienceHead()
//            return view
//        }()
//
//
//        /// 商家特殊视图
//        lazy var buniessView: BusinessHead = {
//
//            let view = BusinessHead()
//            return view
//        }()
//
//        fileprivate var viewHadAppear = false
//
//        override func viewDidAppear(_ animated: Bool) {
//
//            super.viewDidAppear(animated)
//            if viewHadAppear == false{
//                viewHadAppear = true
//
//                animateShowContent()
//            }
//        }
//
//        override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
//            super.touchesEnded(touches, with: event)
//            self.animateDissmissContent()
//        }
//
//        override func viewDidLoad() {
//
//            view.backgroundColor = UIColor.init(white: 0, alpha: 0.5)
//
//            view.addSubview(contentView)
//            contentView.snp.makeConstraints { (make) in
//                make.bottom.equalToSuperview().offset(200)
//                make.left.equalToSuperview().offset(0)
//                make.right.equalToSuperview().offset(0)
//                make.height.equalTo(180)
//            }
//
//            if shareType == .experience {
//                addExperienceUI()
//            }else if shareType == .business {
//                addBusinessUI()
//            }
//        }
//
//        func addExperienceUI(){
//
//            view.addSubview(experienceView)
//            experienceView.snp.makeConstraints { (make) in
//                make.bottom.equalTo(contentView.snp.top).offset(40)
//                make.left.equalToSuperview().offset(9)
//                make.right.equalToSuperview().offset(-9)
//                make.height.equalTo(174)
//            }
//        }
//
//        func addBusinessUI(){
//
//            view.addSubview(buniessView)
//            buniessView.snp.makeConstraints { (make) in
//                make.centerX.equalToSuperview()
//                make.width.equalTo(265)
//                make.height.equalTo(321)
//                make.bottom.equalToSuperview().offset(-247)
//            }
//        }
//
//        func animateShowContent(){
//
//            contentView.snp.updateConstraints { (make) in
//                make.bottom.equalToSuperview().offset(-(self.view.safeInsets().bottom + 0))
//            }
//            UIView.animate(withDuration: 0.3) {
//                self.view.alpha = 1.0
//                self.view.layoutIfNeeded()
//            }
//        }
//
//
//        func animateDissmissContent(complete:(() -> Void)? = nil){
//
//            contentView.snp.updateConstraints { (make) in
//                make.bottom.equalToSuperview().offset(200)
//            }
//            UIView.animate(withDuration: 0.2, animations: {
//                self.view.alpha = 0.0
//                self.view.layoutIfNeeded()
//            }) { (finised) in
//                self.dismiss(animated: false, completion: complete)
//            }
//        }
//
//        @objc func onCloseClick(){
//            self.animateDissmissContent()
//        }
//
//    }
//}
//
////MARK: - --------------YRShare.UI.YRShareViewController: UICollectionViewDelegate--------------
//extension YRShare.UI.YRShareViewController:UICollectionViewDelegate,UICollectionViewDataSource {
//
//    func numberOfSections(in collectionView: UICollectionView) -> Int {
//
//        return 1
//    }
//
//    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
//
//        return dataSource.count
//    }
//
//    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
//
//        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ShareItemCell", for: indexPath) as! ShareItemCell
//        let item = dataSource[indexPath.item]
//        cell.titleLabel.text = item.showInfo.title
//        cell.iconView.image = item.showInfo.icon
//        return cell
//    }
//
//    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//
//        let item = dataSource[indexPath.item]
//
//        animateDissmissContent {
//            self.clickHandle(item)
//        }
//
//    }
//
//
//
//}
//
////MARK: - --------------UIActivityViewController系统分享--------------
//extension YRShare.UI.YRShareViewController{
//
//    /// 系统分享面板
//    class func getSystemShareBoard(with shareInfo:YRShare.ShareInfo,sourceView:UIView ) -> UIActivityViewController{
//
//
//        var shareItems = [shareInfo.title] as [Any]
//        if let picture = shareInfo.picture {//保存图片，只取一个图片资源
//            shareItems.append(picture)
//        }else{
//            if let subtitle = shareInfo.subtitle {
//                shareItems.append(subtitle)
//            }
//            if let image = shareInfo.thumImage {
//                shareItems.append(image)
//            }
//            if let webUrl = shareInfo.webUrl {
//                shareItems.append(webUrl)
//            }
//        }
//
//        let activityController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
//        activityController.excludedActivityTypes = [UIActivity.ActivityType.addToReadingList,UIActivity.ActivityType.print]
//
//        // 兼容ipad
//        activityController.popoverPresentationController?.sourceView = sourceView
//        activityController.popoverPresentationController?.sourceRect = sourceView.bounds
//        activityController.popoverPresentationController?.permittedArrowDirections = .up
//
//        return activityController
//    }
//}
//
////MARK: - --------------YRShare.UI.YRShareViewController中的类--------------
//extension YRShare.UI.YRShareViewController {
//
//    enum ShareUIType {
//        case normal
//        case experience
//        case business
//    }
//
//    class ShareItemCell:CodeLayoutCollectionViewCell {
//
//        lazy var iconView: UIImageView = {
//
//            let view = UIImageView()
//            view.contentMode = .scaleAspectFit
//            return view
//        }()
//
//        lazy var titleLabel: UILabel = {
//
//            let view = UILabel()
//            view.textColor = UIColor.init(rgb: 0x888888)
//            view.font = UIFont.systemFont(ofSize: 10.scaleLength)
//            view.textAlignment = .center
//            return view
//        }()
//
//        override func codeCustomSubviews() {
//
//            contentView.addSubview(iconView)
//            iconView.snp.makeConstraints { (make) in
//                make.top.equalToSuperview().offset(0)
//                make.centerX.equalToSuperview()
//                make.width.height.equalTo(45.scaleLength)
//            }
//
//            contentView.addSubview(titleLabel)
//            titleLabel.snp.makeConstraints { (make) in
//                make.left.right.equalToSuperview()
//                make.bottom.equalToSuperview()
//                make.top.equalTo(iconView.snp.bottom).offset(8)
//            }
//        }
//    }
//
//    /// 分享目的地内容区
//    class ContentView:CodeLayoutView {
//
//        lazy var collectionView: UICollectionView = {
//
//            let layout = YREqualSpaceAlignFlowLayout.init(spaceBetweenCell: 25, alignType: .center)
//            layout.scrollDirection = .horizontal
//            layout.itemSize = CGSize.init(width: 62.scaleLength, height: 62.scaleLength)
//            layout.minimumInteritemSpacing = 3
//            let view = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: layout)
//            view.backgroundColor = .clear
////            view.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0)
//            view.showsHorizontalScrollIndicator = false
//            view.showsVerticalScrollIndicator = false
//            view.alwaysBounceHorizontal = true
//            return view
//        }()
//
//        lazy var backBtn: UIButton = {
//
//            let view = UIButton.init(type: .custom)
////            view.setImage(UIImage.init(named: "share_close"), for: .normal)
//            view.setTitle("取消", for: .normal)
//            view.setTitleColor(UIColor.init(rgb: 0x0E0E0E), for: .normal)
//            view.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .regular)
//            view.backgroundColor = .white
//            return view
//        }()
//
//        override func codeCustomSubviews() {
//
//            backgroundColor = UIColor.init(rgb: 0xF5F5F5)
////            layer.cornerRadius = 18
//            clipsToBounds = true
//
//            addSubview(backBtn)
//            backBtn.snp.makeConstraints { (make) in
//                make.bottom.left.right.equalToSuperview()
//                make.height.equalTo(50.scaleLength)
//            }
//
//            addSubview(collectionView)
//            collectionView.snp.makeConstraints { (make) in
//                make.left.right.equalToSuperview()
//                make.bottom.equalTo(backBtn.snp.top).offset(0)
//                make.top.equalToSuperview().offset(0)
////                make.height.equalTo(65)
//            }
//
//        }
//
//    }
//
//    /// 经验header
//    class ExperienceHead : UIView
//    {
//        let rule = UIButton(type: .system)
//        let backView = UIView()
//        let topImage = UIImageView()
//
//        override init(frame: CGRect) {
//
//            super.init(frame: frame)
//            backgroundColor = .clear
//
//            addSubview(topImage)
//            topImage.backgroundColor = .clear
//            topImage.image = #imageLiteral(resourceName: "share_exp_moneyBack")
//            topImage.snp.makeConstraints { (make) in
//                make.top.equalToSuperview()
//                make.width.equalTo(280)
//                make.centerX.equalToSuperview()
//                make.height.equalTo(72.5)
//            }
//
//            addSubview(backView)
//            backView.backgroundColor = UIColor.white
//            backView.layer.cornerRadius = 18
//            backView.snp.makeConstraints { (make) in
//                make.left.equalToSuperview()
//                make.right.equalToSuperview()
//                make.height.equalTo(102)
//                make.top.equalTo(72.5)
//            }
//
//            let moneyImage = UIImageView()
//            addSubview(moneyImage)
//            moneyImage.backgroundColor = .clear
//            moneyImage.image = #imageLiteral(resourceName: "share_exp_money")
//            moneyImage.snp.makeConstraints { (make) in
//                make.top.equalToSuperview()
//                make.width.equalTo(200)
//                make.centerX.equalToSuperview()
//                make.height.equalTo(111)
//            }
//
//            let title = UILabel()
//            title.text = "分享经验赚积分"
//            title.font = UIFont.systemFont(ofSize: 20)
//            title.textColor = UIColor.init(rgb: 0xF7534F)
//            title.textAlignment = .center
//            backView.addSubview(title)
//            title.snp.makeConstraints { (make) in
//                make.centerX.equalToSuperview()
//                make.top.equalTo(45)
//                make.height.equalTo(28)
//            }
//
//            let tagImage1 = UIImageView()
//            tagImage1.image = #imageLiteral(resourceName: "share_exp_tag")
//            backView.addSubview(tagImage1)
//            tagImage1.snp.makeConstraints { (make) in
//                make.right.equalTo(title.snp.left).offset(-15)
//                make.top.equalTo(53)
//                make.width.equalTo(12)
//                make.height.equalTo(12)
//            }
//
//            let tagImage2 = UIImageView()
//            tagImage2.image = #imageLiteral(resourceName: "share_exp_tag")
//            backView.addSubview(tagImage2)
//            tagImage2.snp.makeConstraints { (make) in
//                make.left.equalTo(title.snp.right).offset(15)
//                make.top.equalTo(53)
//                make.width.equalTo(12)
//                make.height.equalTo(12)
//            }
//
//            backView.addSubview(rule)
//            rule.titleLabel?.font = UIFont.systemFont(ofSize: 12)
//            rule.tintColor = UIColor.init(rgb: 0x989898)
//            rule.setTitle("- 规则 -", for: .normal)
//
//            rule.snp.makeConstraints { (make) in
//                make.centerX.equalToSuperview()
//                make.top.equalTo(title.snp.bottom).offset(5)
//                make.width.equalTo(94)
//                make.height.equalTo(14)
//            }
//        }
//
//        required init?(coder aDecoder: NSCoder) {
//            fatalError("init(coder:) has not been implemented")
//        }
//    }
//
//    /// 商家header
//    class BusinessHead : CodeLayoutView
//    {
//        lazy var topLabel: UILabel = {
//
//            let view = UILabel()
//            view.textAlignment = .center
//            view.font = UIFont.systemFont(ofSize: 15)
//            view.textColor = UIColor.init(rgb: 0x333333)
//            return view
//        }()
//
//        lazy var qrCodeImageView: UIImageView = {
//
//            let view = UIImageView()
//            view.contentMode = .scaleAspectFit
//            return view
//        }()
//
//        private lazy var centerLabel: UILabel = {
//
//            let view = UILabel()
//            view.font = UIFont.systemFont(ofSize: 10)
//            view.textColor = UIColor.init(rgb: 0x666666)
//            view.textAlignment = .center
//            view.text = "用微信识别图中二维码进行结账付款\n可享受特殊折扣优惠。"
//            view.numberOfLines = 2
//            return view
//        }()
//
//        private lazy var bottomLabel: UILabel = {
//
//            let view = UILabel()
//            view.textAlignment = .center
//            view.font = UIFont.systemFont(ofSize: 10)
//            view.textColor = UIColor.init(rgb: 0x999999)
//            view.text = "114啦仅提供技术支持，最终解释权归商家所有"
//            return view
//        }()
//
//        private lazy var backV: UIView = {
//
//            let view = UIView()
//            view.backgroundColor = .white
//            view.layer.cornerRadius = 5
//            view.layer.borderColor = UIColor.init(rgb: 0x999999)?.cgColor
//            view.layer.borderWidth = 0.5
//            return view
//        }()
//
//        override func codeCustomSubviews() {
//
//            backgroundColor = .white
//            layer.cornerRadius = 10
//
//            addSubview(topLabel)
//            topLabel.snp.makeConstraints { (make) in
//                make.top.equalTo(20)
//                make.height.equalTo(21)
//                make.left.right.equalToSuperview()
//            }
//
//            addSubview(backV)
//            backV.snp.makeConstraints { (make) in
//                make.width.height.equalTo(179)
//                make.top.equalTo(topLabel.snp.bottom).offset(15)
//                make.centerX.equalToSuperview()
//            }
//
//            addSubview(qrCodeImageView)
//            qrCodeImageView.snp.makeConstraints { (make) in
//                make.top.equalTo(topLabel.snp.bottom).offset(20)
//                make.width.height.equalTo(169)
//                make.centerX.equalToSuperview()
//            }
//
//            addSubview(centerLabel)
//            centerLabel.snp.makeConstraints { (make) in
//                make.left.right.equalToSuperview()
//                make.top.equalTo(backV.snp.bottom).offset(10)
//                make.height.equalTo(28)
//            }
//
//            addSubview(bottomLabel)
//            bottomLabel.snp.makeConstraints { (make) in
//                make.left.right.equalToSuperview()
//                make.top.equalTo(centerLabel.snp.bottom).offset(19)
//                make.height.equalTo(14)
//            }
//        }
//
////        func setImage(link:String) -> UIImage {
////            let filter = CIFilter.init(name: "CIQRCodeGenerator")
////            filter?.setDefaults()
////            let data = link.data(using: String.Encoding.utf8)
////            filter?.setValue(data, forKeyPath: "inputMessage")
////            if let ciimg = filter?.outputImage {
////                let a = ciimg.transformed(by: CGAffineTransform.init(scaleX: 2, y: 2))
////                codeImage.image = UIImage.init(ciImage: a)
////                return codeImage.image ?? UIImage()
////            }
////            return UIImage()
////        }
////
////        required init?(coder aDecoder: NSCoder) {
////            fatalError("init(coder:) has not been implemented")
////        }
//
//    }
//}
